#ifndef UNDISTORTION_HPP
#define UNDISTORTION_HPP

#include <opencv2/opencv.hpp>
#include <vector>

float undistort_radius(float rd, float k1, float k2, int max_iter = 5);

void undistort_image(const cv::Mat& img, cv::Mat& result, float k1, float k2);

cv::Point2f undistort_point(const cv::Point2f& p, float k1, float k2);

float compute_total_error(const std::vector<cv::Point2f>& points, float k1, float k2);

std::pair<float, float> optimize_k1_k2(const std::vector<cv::Point2f>& points);

#endif // UNDISTORTION_HPP
